home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CPPTASK.ARJ / TSKALLOC.CPP < prev    next >
C/C++ Source or Header  |  1991-08-21  |  978b  |  59 lines

  1. /*
  2.    CPPTask - A Multitasking Kernel For C++
  3.  
  4.    Version 1.0 08-12-91
  5.  
  6.    Ported by Rich Smith from:
  7.  
  8.    Public Domain Software written by
  9.       Thomas Wagner
  10.       Patschkauer Weg 31
  11.       D-1000 Berlin 33
  12.       West Germany
  13.  
  14.    This module contains the memory allocation functions that are needed.
  15.  
  16.    TSKALLOC.CPP - Dynamic memory allocation interface
  17.  
  18.    Subroutines
  19.         tsk_alloc
  20.         tsk_free
  21.         operator new
  22.         operator delete
  23.  
  24. */
  25.  
  26. #include "task.hpp"
  27.  
  28. #include <stdlib.h>
  29.  
  30. farptr tsk_alloc (word size)
  31. {
  32.    farptr ptr;
  33.  
  34.    alloc_resource.request_resource (0L);
  35.    ptr = malloc (size);
  36.    alloc_resource.release_resource ();
  37.  
  38.    return ptr;
  39. }
  40.  
  41.  
  42. void tsk_free (farptr item)
  43. {
  44.    alloc_resource.request_resource (0L);
  45.    free (item);
  46.    alloc_resource.release_resource ();
  47. }
  48.  
  49. void* operator new(size_t size)
  50. {
  51.    return tsk_alloc(size);
  52. }
  53.  
  54.  
  55. void operator delete(void* item)
  56. {
  57.    tsk_free(item);
  58. }
  59.